const dataList = [
    {
        id: 1,
        name: 'class1',
        per_id: 0,
    },
    {
        id: 2,
        name: 'class2',
        per_id: 0,
    },
    {
        id: 3,
        name: 'class3',
        per_id: 0,
    },
    {
        id: 4,
        name: 'class11',
        per_id: 1,
    },
    {
        id: 5,
        name: 'class12',
        per_id: 1,
    },
    {
        id: 6,
        name: 'class13',
        per_id: 1,
    },
    {
        id: 7,
        name: 'class14',
        per_id: 0,
    },
    {
        id: 8,
        name: 'class55',
        per_id: 5,
    },
    {
        id: 9,
        name: 'class999',
        per_id: 2,
    },
]
const father_id = 0 //上层id
// const childerId = ''
function getChilder(fatherId) {
    const fatherList = dataList.filter((item) => item.per_id === fatherId)
    return fatherList.map((item) => {
        const childerList = dataList.filter((item2) => {
            return item.id === item2.per_id
        })
        childerList.forEach((item3) => {
            item3.childer = getChilder(item3.id)
        })
        return {
            ...item,
            childer: childerList,
        }
    })
}

console.log('getChilder(0)', getChilder(0))
getChilder(0)
